<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\Factory
 *
 * @property int $id
 * @property string|null $title
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property string|null $baidu_lat
 * @property string|null $baidu_lng
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property int|null $type 1,租铺 2 买铺 3.转铺
 * @property string|null $tengxun_lat
 * @property string|null $tengxun_lng
 * @property string|null $area 面积
 * @property string|null $images 轮播图
 * @property string|null $price 租金或者其他
 * @property int|null $is_hot 是否是热铺
 * @property string|null $logo 首页图片
 * @method static \Illuminate\Database\Eloquent\Builder|Factory newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|Factory newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|Factory query()
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereArea($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereBaiduLat($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereBaiduLng($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereImages($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereIsHot($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereLogo($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory wherePrice($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereTengxunLat($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereTengxunLng($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereTitle($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereType($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereUpdatedAt($value)
 * @mixin \Eloquent
 * @property string|null $address 地址
 * @property-read \App\Models\City $city
 * @property-read \App\Models\FactoryRentNature $rentNature
 * @property-read \App\Models\FactoryRentType $rentType
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Tag[] $tag
 * @property-read int|null $tag_count
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereAddress($value)
 * @property int|null $rent_type_id 商铺类型
 * @property int|null $rent_nature_id 商铺性质
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereRentNatureId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereRentTypeId($value)
 * @property int|null $is_display 是否上架
 * @property string|null $contact_mobile 业主电话
 * @property string|null $contact_name 业主姓名
 * @property string|null $broker_mobile 经纪人联系电话
 * @property string|null $broker_name 经纪人姓名
 * @property int|null $city_id
 * @property int|null $is_jingxuan 精选热铺
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereBrokerMobile($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereBrokerName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereCityId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereContactMobile($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereContactName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereIsDisplay($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereIsJingxuan($value)
 * @property string|null $content 详情
 * @property int|null $town_id 镇的id
 * @property-read \App\Models\City|null $town
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereContent($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereTownId($value)
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Peitao[] $peitao
 * @property-read int|null $peitao_count
 * @property string|null $status 状态信息
 * @property string|null $guige 规格信息
 * @property string|null $floor 楼层信息
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereFloor($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereGuige($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereStatus($value)
 * @property int|null $view_num 浏览量
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereViewNum($value)
 * @property int|null $shenhe 审核
 * @property int|null $user_id 用户id
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereShenhe($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereUserId($value)
 * @property int|null $zhuanrang 转让费
 * @property int|null $total_price 总价
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereTotalPrice($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereZhuanrang($value)
 * @property string|null $jinshen 进深
 * @property string|null $kaijian 开间
 * @property string|null $cenggao 层高
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereCenggao($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereJinshen($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereKaijian($value)
 * @property int|null $sort 排序
 * @method static \Illuminate\Database\Eloquent\Builder|Factory whereSort($value)
 */
class Factory extends Model
{
    use HasDateTimeFormatter;

    protected $casts = [
        'images' => 'array',
    ];
    public static $mapType = [
        1 => '租铺',
        2 => '买铺',
        3 => '转铺'
    ];
    public static $shenhe = [
        0 => '待审核',
        1 => '审核通过',
        2 => '审核未通过'
    ];
    public static $louceng = [
        '1楼' => '1楼',
        '2楼' => '2楼',
        '3楼' => '3楼',
        '3楼以上' => '3楼以上'
    ];
    public static $statusMap1=[
        '招商中'=>'招商中',
        '经营中'=>'经营中',
    ];
    public static $statusMap2=[
        '招商中'=>'招商中',
        '经营中'=>'经营中',
    ];
    public static $statusMap3=[
        '营业中'=>'营业中',
        '未营业'=>'未营业',
    ];
    protected $table = 'factory';
    public function tag()
    {
        return $this->belongsToMany(Tag::class, 'factory_tag', 'factory_id', 'tag_id');
    }
    public function peitao()
    {
        return $this->belongsToMany(Peitao::class, 'factory_peitao', 'factory_id', 'peitao_id');
    }

    public function city()
    {
        return $this->belongsTo(City::class, 'city_id');
    }

    public function town()
    {
        return $this->belongsTo(City::class, 'town_id');
    }

    public function rentType()
    {
        return $this->belongsTo(FactoryRentType::class, 'rent_type_id');
    }

    public function rentNature()
    {
        return $this->belongsTo(FactoryRentNature::class, 'rent_nature_id');
    }

}
